package com.study.config;

import com.study.quartz.MyQuartz;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @desc:
 * @author: panxiyi
 * @date: 2023/5/6 12:56 下午
 */
@Configuration
public class QuartzConfig {

    @Bean
    public JobDetail printJobDetail() {
        // 绑定具体的工作
        return JobBuilder.newJob(MyQuartz.class).storeDurably().build();
    }

    @Bean
    public Trigger pringJobTrigger() {
        // 绑定对应的触发器
        ScheduleBuilder<? extends Trigger> scheduleBuilder = CronScheduleBuilder.cronSchedule("0/5 * * * * ?");
        return TriggerBuilder.newTrigger().forJob(printJobDetail()).withSchedule(scheduleBuilder).build();
    }
}
